package org.swust.monitor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.swust.monitor.entity.SysDept;
import org.swust.monitor.entity.dto.SysUserCountByDept;

import java.util.List;

@Mapper
public interface SysDeptMapper extends BaseMapper<SysDept>{

    @Select("select count(u.user_id) as worker_count, u.dept_id, d.dept_name \n" +
            "from sys_user u LEFT JOIN sys_dept d \n" +
            "on u.dept_id = d.dept_id \n" +
            "where u.del_flag = 0 \n" +
            "GROUP BY u.dept_id;")
    List<SysUserCountByDept> countWorker();
}
